<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
 <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
        <link rel="stylesheet"th:href="@{/erp/css/style.css}"/>
        <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
        <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
        <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
		   <link rel="stylesheet" th:href="@{/erp/font/css/font-awesome.min.css}" />
<!--[if lte IE 8]>
		  <link rel="stylesheet"th:href="@{/erp/assets/css/ace-ie.min.css}" />
		<![endif]-->
<script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
<script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
<script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
<script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript" ></script>
<script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>
<script th:src="@{/erp/js/lrtk.js}" type="text/javascript" ></script>
<title>订单列表</title>
</head>
<body>
<div class="clearfix">
  <div class="handling_style" id="order_hand">
    <div id="scrollsidebar" class="left_Treeview">
      <div class="show_btn" id="rightArrow"><span></span></div>
      <div class="widget-box side_content" >
        <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
        <div class="side_list">
          <div class="widget-header header-color-green2">
            <h4 class="lighter smaller">订单类型</h4>
          </div>
          <div class="widget-body">
           <ul class="b_P_Sort_list">
             <li><i class="orange  fa fa-reorder"></i><a href="#" id="all">全部订单：[[${whole}]]</a></li>
             <li><i class="fa fa-sticky-note pink "></i> <a href="#" id="complete"  >已完成：[[${complete}]]</a></li>
             <li><i class="fa fa-sticky-note pink "></i> <a href="#" id="notSet" >未发货：[[${notSet}]]</a></li>
            <li><i class="fa fa-sticky-note pink "></i> <a href="#" id="notSend" >待生成：[[${notSend}]]</a></li>
             <li><i class="fa fa-sticky-note pink "></i> <a href="#" id="set" >已发货:[[${set}]]</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="order_list_style" id="order_list_style">
      
  <div class="search_style">
            <span class="l_f">
        <a href="javascript:ovid()"  id="member_add" class="btn btn-warning"><i class="icon-plus"></i>添加订单</a>
  </span>
      <ul class="search_content clearfix">
          <form >
       <li>
           <label class="l_f">订单编号</label>
           <input name="orderId" type="text"  class="text_add" placeholder="输入订单编号"  style=" width:250px"/>
       </li>
       <li>
           <label class="l_f">交易时间</label>
           <input class="inline laydate-icon" name="orderTime" id="start" style=" margin-left:10px;">
       </li>
      <li>
          <input class="inline laydate-icon" name="sldd" type="hidden" >
          <input class="inline laydate-icon" name="orderStatus" type="hidden" id="selectByOrderStatus" >
      </li>
       <li style="width:90px;">
           <button  type="button" class="btn btn-primary" id="selectByForm">查询</button>
       </li>
          </form>
      </ul>
    </div>


      <!--交易订单列表-->
      <div class="Orderform_list">
   <table class="table table-striped table-bordered table-hover" style="width:100%" id="sample-table">
		<thead>
		 <tr>
				<th width="80px">序号</th>
				<th width="120px">订单编号</th>
				<th width="100px">订单类型</th>
				<th width="150px">产品名称</th>
				<th width="100px">支付方式</th>
				<th width="100px">交易金额</th>				
                <th width="100px">交易时间</th>				
				<th width="150px">所属分类</th>
                <th width="80px">数量</th>
				<th width="100px">状态</th>
                <th width="100px">说明</th>                
				<th width="150px">操作</th>
			</tr>
		</thead>
	<tbody>


    </tbody>
    </table>   
      </div>
    </div>
  </div>
</div>

</div>
</div>
</div>
<div class="add_menber" id="add_menber_style" style="display:none">
  
    <ul class=" page-content">
     <li style="position: relative;left: -5px;">
         <label class="label_name" style="width: 85px;">订单编号：</label>
         <span class="add_name">
             <input name="orderId" type="text" id="orderId"  class="text_add"/>
         </span>
         <div class="prompt r_f"></div>
     </li>
        <li><label class="label_name">产品名称：</label>
            <span class="add_name">
         <select  name='proId' style='width:150px;margin-left:10px;' id="proId">
             <option th:each="product : ${products}"  th:value="${product.id}" th:text="${product.id}"></option>
         </select>
        </span>
            <div class="prompt r_f"></div>
        </li>
    <li>
        <label class="label_name" >付款情况：</label>
        <span class="add_name">
         <input name="payment" type="text" id="payment" class="text_add"/>
     </span>
    </li>
    <li>
        <label class="label_name" >收货人：</label>
        <span class="add_name">
         <input name="consignee" type="text" id="consignee"  class="text_add"/>
     </span>
    </li>
    <li>
        <label class="label_name" >收货地址：</label>
        <span class="add_name">
         <input name="takeAddress" type="text" id="takeAddress" class="text_add"/>
     </span>
    </li>
    <li>
        <label class="label_name" >订单备注：</label>
        <span class="add_name">
         <input name="orderMark" type="text" id="orderMark" class="text_add"/>
     </span>
    </li>
	 <li>
         <label class="label_name" >交易金额：</label>
         <span class="add_name">
             <input name="money" type="text" id="money" class="text_add"/>
         </span>
     </li>
    <li>
        <label class="label_name" >订单类型：</label>
        <span class="add_name">
         <input name="orderType" type="text"  id="orderType" class="text_add"/>
     </span>
    </li>
     <li>
         <label class="label_name" >支付方式：</label>
         <span class="add_name">
             <select name="payType" id="payType" style='width:150px;margin-left:10px;'>
                 <option value="线上">在线支付</option>
                 <option value="线下">线下支付</option>
         </select>
        </span>
	</li>
	<li >
        <label class="label_name">数量：</label>
        <span class="add_name">
            <input name="sum" type="text" id="sum" class="text_add" />
        </span>
        <div class="prompt r_f"></div>
    </li>
	<li >
        <label class="label_name">下单者：</label>
        <span class="add_name">
            <input name="orderPerson" type="text" id="orderPerson" class="text_add" />
        </span>
        <div class="prompt r_f"></div>
    </li>
    </ul>
 </div>	 
  <!--编辑打印机图层-->

 </div>
</div>
</div>
 </div>
</div>
</body>
</html>
<script>

 

        $(function() {
            $("#order_hand").fix({
                float : 'left',
                //minStatue : true,
                skin : 'green',
                durationTime :false,
                spacingw:30,//设置隐藏时的距离
                spacingh:250,//设置显示时间距
                table_menu:'.order_list_style',
            });
        });
         laydate({
            elem: '#start',
            event: 'focus',
            format: 'YYYY-MM-DD hh:mm:ss',
            istime: true
        });



        //初始化宽度、高度
         $(".widget-box").height($(window).height());
        $(".order_list_style").width($(window).width()-220);
         $(".order_list_style").height($(window).height()-30);
          //当文档窗口发生改变时 触发
            $(window).resize(function(){
            $(".widget-box").height($(window).height());
             $(".order_list_style").width($(window).width()-234);
              $(".order_list_style").height($(window).height()-30);
        });
        /*状态-结束*/
        function member_stop(obj,id){
            layer.confirm('确认修改状态为已结束？',function(index){
                $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="进行中"><i class="fa fa-close bigger-120"></i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已结束</span>');
                $(obj).remove();
                layer.msg('已结束!',{icon: 5,time:1000});
            });
        }


        /*人员-删除*/
        function Order_form_del(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
            });
}
        //订单列表
        jQuery(function($) {

                var oTable1 = $('#sample-table').dataTable( {
                    "serverSide": true,
                "aaSorting": [
                    [
                        1, "desc"
                    ]
                ],//默认第几个排序
                "bStateSave": true,//状态保存
                "aoColumnDefs": [
                  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                  {"orderable":false,"aTargets":[2,3,4,5,6,7,8]}// 制定列不参与排序
                ],
                    "ajax": {
                        "url": '/order/orderList',
                        "type": 'GET',
                        "dataSrc": 'data',
                        "data": function (message) {

                            var data = $('form').serialize();


                            console.log(data)

                            //获取分页信息
                            var pages = {
                                start: message.start,

                                length: message.length,
                            };
                            data = data + '&' + $.param(pages);
                            return data;

                        }
                    },
                    "columns": [
                        {"data": "id"},
                        {"data": "orderId"},
                        {"data": "orderType"},
                        {"data": "product.productName"},
                        {"data": "payType"},
                        {"data": "money"},
                        {"data": "orderTime"},
                        {"data": "product.productType"},
                        {"data": "sum"},
                        {"data": "orderStatus"},
                        {"data": "explain"},

                        {
                            "data": "orderStatus", "createdCell": function (td, cellData, rowData, row, col) {
                                if(cellData == '已发货'){
                                    $(td).empty().append(' <a title="查看详情"  href="/order/dealAuditing"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">查看详情</i></a> ');
                                }else if (cellData == '已完成') {
                                    $(td).empty().append(' <a title="查看详情"  href="/order/dealAuditing"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">查看详情</i></a> ');
                                }else if (cellData == '未排单'){
                                    $(td).empty().append(' <a title="排单"  href="/order/sort"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">排单</i></a> ');
                                }else if (cellData == '未发货'){
                                    $(td).empty().append(' <a title="发货"  href="/order/aaDF"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">发货</i></a> ');
                                }else if (cellData == '待生成'){
                                    $(td).empty().append(' <a title="待生成"  href="/production/sc_dscPage"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">待生成</i></a>  ');
                                }else if (cellData == '已入库'){
                                    $(td).empty().append(' <a title="已入库"  href="/warehouse/warehouse_crk/out_storage_orderPage"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">待出库</i></a>  ');
                                }else if (cellData == '已出库'){
                                    $(td).empty().append(' <a title="已出库"  href="/order/dealAuditing"  class="btn btn-xs btn-success" ><i class="icon-list bigger-120">已出库</i></a>  ');
                                }

                            }
                        },

                    ]


                } );

            $("#selectByForm").on('click',function () {
                oTable1.fnUpdate();
                // oTable1.ajax.reload();
            });

            $("#complete").on('click',function () {
                $('#selectByOrderStatus').val("已完成");
                oTable1.fnUpdate();
            });

            $("#notSet").on('click',function () {
                $('#selectByOrderStatus').val("未发货");
                oTable1.fnUpdate();
            });

            $("#notSend").on('click',function () {
                $('#selectByOrderStatus').val("待生成");
                oTable1.fnUpdate();
            })

            $("#set").on('click',function () {
                $('#selectByOrderStatus').val("已发货");
                oTable1.fnUpdate();
            })

            $("#all").on('click',function () {
                $('#selectByOrderStatus').val("");
                oTable1.fnUpdate();
            })


            $('#member_add').on('click', function(){
                layer.open({
                    type: 1,
                    title: '添加订单',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area : ['800px' , ''],
                    content:$('#add_menber_style'),
                    btn:['提交','取消'],
                    yes:function(index,layero){

                        var data ={};
                        data.orderId = $('#orderId').val();
                        data.payment = $('#payment').val();
                        data.consignee = $('#consignee').val();
                        data.takeAddress = $('#takeAddress').val();
                        data.orderMark = $('#orderMark').val();
                        data.money = $('#money').val();
                        data.orderType = $('#orderType').val();
                        data.payType = $('#payType').val();
                        data.sum = $('#sum').val();
                        data.orderPerson = $('#orderPerson').val();
                        data.proId = $('#proId').val();

                        $.ajax({
                            url:'/order/addOrderList'
                            ,type:'post'
                            ,data:JSON.stringify(data)
                            ,dataType:'json'
                            ,contentType:'application/json'
                            ,success: function(msg){
                                var num=0;
                                var str="";
                                $(".add_menber input[type$='text']").each(function(n){
                                    if($(this).val()=="")
                                    {

                                        layer.alert(str+=""+$(this).attr("name")+"不能为空！\r\n",{
                                            title: '提示框',
                                            icon:0,
                                        });
                                        num++;
                                        return false;
                                    }
                                });
                                if(num>0){  return false;}
                                else{
                                    layer.alert('添加成功！',{
                                        title: '提示框',
                                        icon:1,
                                    });
                                    layer.close(index);
                                    oTable1.fnUpdate();
                                  var num1 = parseInt($("#all").text().slice(5,7))+1;
                                    $("#all").text("全部订单："+num1);

                                }


                            }
                        });

                    }
                });
            });







                         //全选操作
                        $('table th input:checkbox').on('click' , function(){
                            var that = this;
                            $(this).closest('table').find('tr > td:first-child input:checkbox')
                            .each(function(){
                                this.checked = that.checked;
                                $(this).closest('tr').toggleClass('selected');
                            });

                        });
                    });


</script>

